- /* slmlsmns.cpp by K.Tsuru */
- // function ID = 234
- /********************************************************************
- SLong class
- It subtracts a positive short implemented for the decrement operator.
- The statement
- return (*this = *this - a);
- has a large overhead, because it calls a constructor SLong(a).
- *********************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- void SLong::LsMinus(fType a){
- if(!a) return;
- if(Sign(234) < 0){ // -x - a = -(x+a)
- SetSign(1); LsAdd(a); SetSign(-1);
- return;
- }
- if(aHead == 0){ //one figure including a=0
- long r = (long)figure[0]-(long)a;
- SetLong(r); return;
- }
- // aHead >0, aTail >= 0, sign > 0
- fType rdx = Radix();
- int r = (int)rdx-(int)a;
- if(figure[0] >= a){
- figure[0] -= a;
- while(figure[aTail] == 0) aTail++;
- } else if(r > 0){ //figure[0] < a < radix
- //*this does not become negative because aHead > 0.
- fType rdx1 = rdx - 1;
- figure[aTail]--; //It borrows one from upper.
- if(figure[aHead] == 0) aHead--; // figure[aHead] == 1 && aHead == aTail
- for(uint i = 1u; i < aTail; i++) figure[i] = rdx1;
- figure[0] = (fType)r; aTail = 0; // r > 0
- if( 2u*(aHead+1) <= figure.size() ) DoCutDown();
- } else { //a >= radix
- *this -= (double)a;
- }
- }
slmlsmns.cpp : last modifiled at 2017/03/13 14:32:01(1,303 bytes)
created at 2017/10/07 10:26:49
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).